/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bkcad;

/**
 *
 * @author hoangpt
 */
class Prime {

  public Prime() {
  }

  void printList() {
    //loop from 1 -100
    int max = 100;
    for (int i = 2; i <= max; i++) {
        /**
         * check number is prime
         */
        if(this.isPrime(i)){
          System.out.println(i);
        } 
    }
  }

  /**
   * Check prime
   * @param n
   * @return 
   */
  private boolean isPrime(int n) {
    /**
     * for i->2 to square root n, if mod==0->not prime
     */
    for (int i = 2; i <= Math.sqrt(n); i++) {
      if (n%i == 0) {
        return false;
      }
    }
    
    return true;
  }
}
